package cn.edu.zust.companyservice.mapper;

import Company.Dto.Company;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CompanyMapper {
    @Insert("INSERT INTO companies (account, password, name, size, license, brand, description, status, email) " +
            "VALUES (#{account}, #{password}, #{name}, #{size}, #{license}, #{brand}, #{description}, #{status}, #{email})")
    void delivertCompany(Company company);

    @Select("SELECT * FROM companies WHERE status = 0")
    List<Company> auditCompany();

    @Select("SELECT * FROM companies WHERE status != 0")
    List<Company> getAuditedCompany();

    @Select("SELECT * FROM companies")
    List<Company> findAllCompany();

    @Select("SELECT * FROM companies WHERE id = #{id}")
    Company findCompanyById(int id);

    @Update("UPDATE companies SET status = #{status} WHERE id = #{id}")
    void shiftStatus(@Param("id") int id, @Param("status") int status);

    // 定义更新公司账号和密码的方法
    @Update("UPDATE companies SET account = #{account}, password = #{password} WHERE id = #{id}")
    void sentAccountAndPassword(@Param("id") int id, @Param("account") String account, @Param("password") String password);

    @Select("select password from companies where account = #{account}")
    String getPasswordByAccount(String account);
}
